// 导入需要的config和request
import confing from '../config/config.js';
import request from '../util/request.js';
// 申明请求对象
const teamMemberRequest = {
  // 请求的基本url
  BASE_URL: confing.CAL_URL + "/teamMember",

  //根据用户名查询班组成员信息
  selectByUserName(userName,callback){
    let url = this.BASE_URL + "/selectByUserName?userName=" + userName;
    // 发送请求
    request.get(url,callback);
  },
  //删除班组成员
  deleteByIds(memberIds,callback){
    // 拼接URL
    let url = this.BASE_URL + "/deleteByIds?t=1";
    if(memberIds != undefined){
      memberIds.forEach(memberId => {
            url += "&memberIds=" + memberId;
        });
        request.delete( url,callback);
    }
  },
  // 获取所有成员
  getAll(callback){
    let url = this.BASE_URL + "/getAll";
    // 发送请求
    request.get(url,callback);
  },
  //根据用户id查询数据
  getByUserId(userId,callback){
    let url = this.BASE_URL + "/getByUserId?userId=" + userId;
    // 发送请求
    request.get(url,callback);
  },
  //根据班组编号查询班组成员
  list(teamCode,callback){
    let url = this.BASE_URL + "/list?teamCode=" + teamCode;
    // 发送请求
    request.get(url,callback);
  },
  //添加班组用户
  save(teamCode,users,callback){
    let url = this.BASE_URL + "/save";
    request.post(url,{"teamCode":teamCode,"users":users},callback);
},
}
// 将dictRequest暴漏出去
export default teamMemberRequest;